package com.srzk.youthleagueback.mapper;

import com.srzk.youthleagueback.pojo.Registration;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface RegistrationMapper {

    @Insert("insert into registration (user, year,type ,content)" +
            "values (#{registration.user}, #{registration.year},#{registration.type}, " +
            "#{registration.content})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(@Param("registration") Registration record);

    @Select("SELECT * FROM registration WHERE user = #{user} AND year = #{year} AND type = #{type}")
    Registration selectByPrimaryKey(@Param("user") String user, @Param("year") String year, @Param("type") Integer type);

    List<Registration> selectAll();

    @Update("UPDATE  registration set content = #{registration.content} where user = #{registration.user} and type = #{registration.type} and year = #{registration.year}")
    int updateByPrimaryKey(@Param("registration") Registration record);
}